import java.math.BigDecimal;
public class DoubleTest{
	public static void main(String[] args) {
		//声明一个float类型并赋值
		// float f1 = 3.1415926;// 错误: 不兼容的类型: 从double转换到float可能会有损失 直接写出来的小数默认为double
		float f1 = 3.1415926f;
		System.out.println("f1 = " + f1);//f1 = 3.1415925

		float f2 = 3.1415925f;
		System.out.println("f2 = " + f2);//f2 = 3.1415925

		float f3 = 3.1415924f;
		System.out.println("f3 = " + f3);//f3 = 3.1415925

		float f4 = 3.1415921f;
		System.out.println("f4 = " + f4);//f4 = 3.141592

		double d1 = 3.1415926;
		System.out.println("d1 = " + d1);


		System.out.println("-----------------------------------------");
		//笔试考点
		System.out.println(0.009 + 0.001);	//0.30000000000000004  浮点数不能实现精确计算可能会有误差，若希望实现精确计算可借助java.math.BigDecimal类型
		// 0.0000001001001101
		// 0.0000000001000001
		BigDecimal bdc1 = new BigDecimal(0.009) ;
		BigDecimal bdc2 = new BigDecimal(0.001);
		BigDecimal bdc3 = bdc1.add(bdc2);
		System.out.println("bdc3 = " + bdc3); 
	}
}